/**
 * @author yb
 * @version  1.0
 * @time 下午10:15:38
 */
package com.teaching.common;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
 * @author yb
 *
 */
public class DBTool {

	static {
        try {       
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

	/**
	 * 
	 */
	public DBTool() {
		// TODO Auto-generated constructor stub
	}

	 public static Connection getConnection() {
	        //String url = "jdbc:mysql://" + JdbcConstants.SOURCE_HOST + ":" + JdbcConstants.SOURCE_PORT + "/" + JdbcConstants.SOURCE_DATABASE + "?serverTimezone=GMT&useSSL=false&characterEncoding=utf8&autoReconnect=true";
	        String url = "jdbc:sqlserver://" + JdbcConstants.SOURCE_HOST + ":" + JdbcConstants.SOURCE_PORT + ";" + "DatabaseName="+JdbcConstants.SOURCE_DATABASE ;
	        String user = JdbcConstants.SOURCE_USER;
	        String password = JdbcConstants.SOURCE_PASSWORD;
	        Connection con = null;
	        try {
	            con = DriverManager.getConnection(url, user, password);
	        } catch (SQLException e) {
	            e.printStackTrace();
	        }
	       
	        return con;
	    }
	/**
	 * @author yb
	 * @function 
	 * @param args
	 * @return void
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		DBTool.getConnection();
	}

}
